rebase#129
Conversation
…ic Updates (#117) * Update rrdInterface.c * Update rrdInterface.c * Update rrdInterface.c * Update cov_build.sh * Update configure.ac * Update rrdInterface.c * Update rrdInterface.h * Update cov_build.sh * Update rrdInterface.c * Update rrdInterface.h * Update rrdInterface.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
…method (#123) * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdInterface.h * Update rrdCommon.h * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdDynamic.c * Update rrdJsonParser.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdInterface.h * Update rrdInterface.h * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c
…method (#125) * Update rrdIarmEvents.c * Update rrdInterface.c * Update rrdInterface.c * Update cov_build.sh * Update rrdIarmEvents.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
…d message type (SCXI11BEI) (#121) * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdInterface.c * Update rrdInterface.c * Update rrdInterface.c * Update rrdJsonParser.c * Update rrdInterface.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdEventProcess.c * Update rrdInterface.c * Update rrdInterface.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
|
|
Added release to fix remotedebugger bug fixes
… process exited with error code." (#134) * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c
…rogress (#136) * Update rrdInterface.c * Update rrdInterface.c * Update rrdInterface.c
Release 1.2.8 tag for RRD
* Update Client_Mock.cpp * Update Client_Mock.h * Update rrdUnitTestRunner.cpp * Update rrdUnitTestRunner.cpp * Update rrdUnitTestRunner.cpp * Update rrdInterface.c * Update rrdInterface.h * Update rrdRunCmdThread.c * Update rrdIarmEvents.c * Update rrdInterface.h * Update rrdDynamic.c * Update code-coverage.yml
Create deepsleep_main.c Update Makefile Create power_controller.h Update run_l2.sh Update cov_build.sh Create pwrMgr.h Update cov_build.sh Update cov_build.sh Update Makefile Rename deepsleep_main.c to main.c Update Makefile update Makefile Delete test/functional-tests/tests/rrdIarmEvents.c Update run_l2.sh Update remote_debugger.json Update remote_debugger.json Create test_deepsleep_static.py Update run_l2.sh Update run_l2.sh Create test_deepsleep_dynamic.py Update run_l2.sh Update rrdInterface.c Update create_json.sh Create test_append.py Create test_category.py Update test_rrd_dynamic_profile_missing_report.py Create test_rrd_dynamic_with_download_harmful.py Create test_rrd_negative.py Update configure.ac Update cov_build.sh Update run_l2.sh Update main.c Rename main.c to deepsleep_main.c Update Makefile Create rrd_append_report.feature Create rrd_deepsleep_static.feature Create rrd_deepsleep_dynamic.feature Create rrd_dynamic_with_download_harmful_report.feature Update rrd_dynamic_profile_missing_report.feature Update test_rrd_dynamic_profile_missing_report.py Update cov_build.sh Update test_rrd_single_instance.py Update test_category.py Update run_l2.sh Update test_rrd_dynamic_profile_missing_report.py Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdIarmEvents.c Update rrdIarmEvents.c Delete test/functional-tests/tests/test_deepsleep_dynamic.py Delete test/functional-tests/tests/test_rrd_negative.py Update run_l2.sh Update test_category.py Update cov_build.sh Update configure.ac Update configure.ac Delete test/functional-tests/features/rrd_deepsleep_dynamic.feature Update rrd_dynamic_profile_missing_report.feature Update rrd_dynamic_profile_missing_report.feature Delete test/functional-tests/tests/test_rrd_dynamic_with_download_harmful.py Delete test/functional-tests/tests/deepsleep_main.c Delete test/functional-tests/tests/Makefile Update run_l2.sh Update run_l2.sh Delete test/functional-tests/features/rrd_dynamic_with_download_harmful_report.feature Create rrd_dynamic_profile_subcategory_report.feature Update run_l2.sh Rename test_append.py to test_rrd_append_report.py Rename test_category.py to test_rrd_dynamic_subcategory_report.py Rename test_deepsleep_static.py to test_rrd_deepsleep_static_report.py Rename rrd_deepsleep_static.feature to rrd_deepsleep_static_report.feature Update rrd_dynamic_profile_missing_report.feature Update rrd_dynamic_profile_missing_report.feature Update rrd_dynamic_profile_missing_report.feature
RDK-56291 - [RDKE] Increase L2 Test Coverage For Remote Debugger : Target 80% [ Phase 2 ]
…elop Deploy cla action
Deploy fossid_integration_stateless_diffscan_target_repo action
…rget 80% [ Phase 2 ] (#157) * Update rrdInterface.c * Update rrdIarmEvents.c * Update configure.ac * Update cov_build.sh * Update remote_debugger.json * Update create_json.sh * Create Makefile * Create deepsleep_main.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
RRD 1.2.9 release
There was a problem hiding this comment.
Pull request overview
This PR is a rebase containing multiple feature additions and improvements to the Remote Debugger component, including:
- Enhanced L2 test coverage with new test scenarios for dynamic subcategory reports, deep sleep, and append functionality
- Deep sleep event handling support with power manager integration
- Unit test infrastructure improvements with comprehensive mock support
- Documentation additions for uploadRRDLogs migration to C
- Build system updates and workflow improvements
Key Changes
- New L2 test files for dynamic profiles, deep sleep scenarios, and append operations
- Enhanced PID handling in single instance tests with proper parsing
- Deep sleep event processing with power controller integration
- Memory management improvements in event processing
- Comprehensive unit test coverage expansion
- New mock infrastructure for power manager testing
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/functional-tests/tests/test_rrd_single_instance.py | Enhanced PID handling with proper list parsing and validation |
| test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py | New L2 test for dynamic profile subcategory reports |
| test/functional-tests/tests/test_rrd_deepsleep_static_report.py | New L2 test for deep sleep static reports |
| test/functional-tests/tests/test_rrd_append_report.py | New L2 test for append request scenarios |
| test/functional-tests/tests/power_controller.h | New power controller API definitions for deep sleep |
| test/functional-tests/tests/deepsleep_main.c | Test main for deep sleep event handling |
| src/rrdRunCmdThread.c | Added RemainAfterExit flag to systemd-run commands |
| src/rrdJsonParser.c | Added deep sleep detection logic |
| src/rrdInterface.h/c | Interface updates for IARM support compilation |
| src/rrdIarmEvents.c | Refactored power manager event handling |
| src/rrdEventProcess.c | Improved memory management with null checks |
| src/rrdDynamic.c | Fixed buffer size calculation in string copy |
| src/unittest/rrdUnitTestRunner.cpp | Extensive unit test additions and mock updates |
| src/unittest/mocks/*.h/cpp | Updated mock infrastructure for testing |
| docs/*.md | New comprehensive documentation for uploadRRDLogs |
| configure.ac | Added L2 support configuration option |
| cov_build.sh | Updated build flags for coverage |
| CHANGELOG.md | Version updates and changelog entries |
| .github/workflows/* | Workflow improvements and CLA addition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| DEBUG_FILE = "Adding Details of Debug commands to Output File" | ||
| assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) | ||
|
|
||
| issue_string = "DEEPSLEEP" |
There was a problem hiding this comment.
Variable issue_string is not used.
| @@ -0,0 +1,134 @@ | |||
| import json | |||
| from helper_functions import * | |||
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
| # limitations under the License. | ||
| ########################################################################## | ||
|
|
||
| from helper_functions import * |
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
|
|
||
| import json | ||
| import subprocess | ||
| from helper_functions import * |
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
| # limitations under the License. | ||
| ########################################################################## | ||
|
|
||
| import json |
There was a problem hiding this comment.
Import of 'json' is not used.
* RDK-58172: integrate dcm-agent uploadstblogs and cleanup logging; update Makefile and upload flow * Add unit tests for RRD upload orchestration This file contains unit tests for the RRD upload orchestration, covering various aspects such as configuration loading, system information retrieval, log directory validation, and the entire upload workflow. * Update Makefile.am * Remove uploadRRDLogs program from Makefile * Refactor uploadDebugoutput to use upload API Updated the uploadDebugoutput function to call the upload API instead of executing a script. Enhanced logging for upload orchestration success and failure. * Refactor upload orchestration into rrd_upload_orchestrate Refactor upload orchestration logic into a separate function and remove deprecated main function. * Update rrd_config.h * Include common_device_api.h in rrd_sysinfo.h Added inclusion of common_device_api.h for device API access. * Add comprehensive functional tests for C API upload orchestration - Add BDD feature file with 20 test scenarios for rrd_upload_orchestrate - Add Python test implementation with 14 test functions - Test coverage includes: * Valid and invalid parameter handling * Configuration loading from multiple sources (properties, RFC, DCM) * MAC address retrieval and timestamp generation * Issue type sanitization and normalization * Archive creation and format validation * Upload execution and lock handling * Cleanup operations * Error code propagation (codes 1-11) * Comprehensive logging verification * Integration with uploadDebugoutput wrapper - Tests validate the complete flow from event trigger through C API execution to upload completion - Helper class provides utilities for test setup, archive validation, and log verification Refactor source validation and log handling. Improve error handling for directory operations and add functionality to move live logs. * Refactor log upload handling and cleanup process Updated log upload process to handle LOGUPLOAD_ENABLE case and adjusted archive creation and upload paths.
* RDKEMW-12334-The log entries in remote-debugger.log RDKEMW-12334-The log entries in remote-debugger.log differ between C binary files and script files when compared * Change the log from Debug to Info * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 62 out of 62 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if '.' in ISSUE_STRING: | ||
| ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') | ||
| else: | ||
| node = ISSUE_STRING |
There was a problem hiding this comment.
Variable node is not used.
| ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') | ||
| else: | ||
| node = ISSUE_STRING | ||
| subnode = None |
There was a problem hiding this comment.
Variable subnode is not used.
| node = ISSUE_STRING | ||
| subnode = None | ||
|
|
||
| ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json" |
There was a problem hiding this comment.
Variable ISSUE_FOUND is not used.
| # limitations under the License. | ||
| ########################################################################## | ||
|
|
||
| from helper_functions import * |
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
RRD release 1.3.1
…ode (#178) * Update Makefile.am * Update rrdExecuteScript.c * Update rrd_upload.h * Update Makefile.am * Update Makefile.am * Update Makefile.am * Update Makefile.am --------- Co-authored-by: nhanasi <navihansi@gmail.com>
This pull request addresses Coverity defects in the RDK Remote Debugger Device Management code, focusing on fixing memory leaks, buffer overflows, and resource handling issues. Changes: Added NULL checks for memory allocations (malloc, strdup, fread) with proper error handling and resource cleanup Fixed buffer overflow vulnerabilities by using correct size parameters in strncpy/strncat operations Corrected file pointer closure to only occur when pointers are valid (v_secure_pclose moved inside if blocks) Fixed memory management issues with rfcbuf allocations and ownership Co-authored-by: mtirum011 <madhubabu_tirumala@comcast.com>
Remote Debugger 1.3.2 release
| # Path to the existing JSON file | ||
| file_path = "/etc/rrd/remote_debugger.json" | ||
|
|
||
| # Read the existing JSON data | ||
| with open(file_path, "r") as json_file: | ||
| data = json.load(json_file) | ||
|
|
||
| # New entry to add | ||
| new_entry = { | ||
| "Test": { | ||
| "TestRun4": { | ||
| "Commands": "cat /version.txt;cat /tmp/.deviceDetails.cache", | ||
| "Timeout": 10 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Update the JSON data with the new entry | ||
| data.update(new_entry) | ||
|
|
||
| # Write the updated data back to the JSON file | ||
| with open(file_path, "w") as json_file: | ||
| json.dump(data, json_file, indent=4) |
There was a problem hiding this comment.
This test module performs file I/O and overwrites /etc/rrd/remote_debugger.json at import time. If the file is missing or the test runner lacks permissions, collection will fail before any tests run, and it also makes the suite order-dependent. Move this JSON read/update/write logic into a dedicated test (or a setup/fixture) and prefer writing to a temporary copy of the config rather than mutating /etc directly.
| pIssueNode = (issueNodeData *)malloc(sizeof(issueNodeData)); | ||
| if(pIssueNode) | ||
| { | ||
| getIssueInfo((char *)rbuf->mdata, pIssueNode); // issue data extract | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Extracted Node %s and Sub Node %s \n", __FUNCTION__, __LINE__, pIssueNode->Node, pIssueNode->subNode); | ||
| if (rbuf->appendMode) | ||
| { | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Received append request to process static and dynamic profiles... \n", __FUNCTION__, __LINE__); | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Reading dynamic profile command info... \n", __FUNCTION__, __LINE__); | ||
| dynamicprofiledata = processIssueTypeInDynamicProfileappend(rbuf, pIssueNode); | ||
| if (dynamicprofiledata == NULL) | ||
| { | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Dynamic Profie Info not found, Download RDM package... \n", __FUNCTION__, __LINE__); | ||
| } | ||
| else | ||
| { | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Read complete for Dynamic Profile: RFCValue: %s, Command: %s, Timeout: %d... \n", __FUNCTION__, __LINE__, dynamicprofiledata->rfcvalue, dynamicprofiledata->command, dynamicprofiledata->timeout); | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Reading static profile command info... \n", __FUNCTION__, __LINE__); | ||
| staticprofiledata = processIssueTypeInStaticProfileappend(rbuf, pIssueNode); | ||
| if (staticprofiledata == NULL) | ||
| { | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Static Command Info not found for IssueType!!! \n", __FUNCTION__, __LINE__); | ||
| // Free dynamicprofiledata since we can't proceed | ||
| if (dynamicprofiledata != NULL) | ||
| { | ||
| if (dynamicprofiledata->rfcvalue != NULL) | ||
| { | ||
| free(dynamicprofiledata->rfcvalue); | ||
| } | ||
| if (dynamicprofiledata->command != NULL) | ||
| { | ||
| free(dynamicprofiledata->command); | ||
| } | ||
| free(dynamicprofiledata); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Read complete for Static Profile: RFCValue: %s, Command: %s, Timeout: %d... \n", __FUNCTION__, __LINE__, staticprofiledata->rfcvalue, staticprofiledata->command, staticprofiledata->timeout); | ||
| //Remove the double quotes | ||
| size_t staticstrlen = strlen(staticprofiledata->command); | ||
| size_t dynamicstrlen = strlen(dynamicprofiledata->command); | ||
| if (staticstrlen > 0 && staticprofiledata->command[staticstrlen - 1] == '"') { | ||
| staticprofiledata->command[staticstrlen - 1] = '\0'; | ||
| } | ||
| if (dynamicprofiledata->command[0] == '"') { | ||
| dynamicprofiledata->command[0] = COMMAND_DELIM; | ||
|
|
||
| // Check if commands are NULL before using them | ||
| if (dynamicprofiledata->command == NULL || staticprofiledata->command == NULL) | ||
| { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Command is NULL in dynamic or static profile... \n", __FUNCTION__, __LINE__); | ||
| // Free dynamicprofiledata | ||
| if (dynamicprofiledata != NULL) | ||
| { | ||
| if (dynamicprofiledata->rfcvalue != NULL) | ||
| { | ||
| free(dynamicprofiledata->rfcvalue); | ||
| } | ||
| if (dynamicprofiledata->command != NULL) | ||
| { | ||
| free(dynamicprofiledata->command); | ||
| } | ||
| free(dynamicprofiledata); | ||
| } | ||
| // Free staticprofiledata | ||
| if (staticprofiledata != NULL) | ||
| { | ||
| if (staticprofiledata->rfcvalue != NULL) | ||
| { | ||
| free(staticprofiledata->rfcvalue); | ||
| } | ||
| if (staticprofiledata->command != NULL) | ||
| { | ||
| free(staticprofiledata->command); | ||
| } | ||
| free(staticprofiledata); | ||
| } | ||
| } | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Static Profile Commands: %s, Dynamic Profile Commands: %s\n", __FUNCTION__, __LINE__, staticprofiledata->command, dynamicprofiledata->command); | ||
|
|
||
| size_t appendstrlen = ((staticstrlen - 1) + dynamicstrlen + 1); | ||
| char *appendcommandstr = (char *)realloc(staticprofiledata->command, appendstrlen); | ||
| if (appendcommandstr == NULL) { | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed... \n", __FUNCTION__, __LINE__); | ||
| else | ||
| { | ||
| //Remove the double quotes | ||
| size_t staticstrlen = strlen(staticprofiledata->command); | ||
| size_t dynamicstrlen = strlen(dynamicprofiledata->command); | ||
| if (staticstrlen > 0 && staticprofiledata->command[staticstrlen - 1] == '"') { | ||
| staticprofiledata->command[staticstrlen - 1] = '\0'; | ||
| staticstrlen--; // Update length after removing trailing quote | ||
| } | ||
| if (dynamicprofiledata->command[0] == '"') { | ||
| dynamicprofiledata->command[0] = COMMAND_DELIM; | ||
| } | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Static Profile Commands: %s, Dynamic Profile Commands: %s\n", __FUNCTION__, __LINE__, staticprofiledata->command, dynamicprofiledata->command); | ||
|
|
||
| size_t appendstrlen = (staticstrlen + dynamicstrlen + 1); | ||
| char *appendcommandstr = (char *)realloc(staticprofiledata->command, appendstrlen); | ||
| if (appendcommandstr == NULL) { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s:%d]: Memory Allocation Failed... \n", __FUNCTION__, __LINE__); | ||
| // Free staticprofiledata on realloc failure | ||
| if (staticprofiledata != NULL) | ||
| { | ||
| if (staticprofiledata->rfcvalue != NULL) | ||
| { | ||
| free(staticprofiledata->rfcvalue); | ||
| } | ||
| if (staticprofiledata->command != NULL) | ||
| { | ||
| free(staticprofiledata->command); | ||
| } | ||
| free(staticprofiledata); | ||
| staticprofiledata = NULL; // Set to NULL to prevent double-free | ||
| } | ||
| // Free dynamicprofiledata on realloc failure | ||
| if (dynamicprofiledata != NULL) | ||
| { | ||
| if (dynamicprofiledata->rfcvalue != NULL) | ||
| { | ||
| free(dynamicprofiledata->rfcvalue); | ||
| } | ||
| if (dynamicprofiledata->command != NULL) | ||
| { | ||
| free(dynamicprofiledata->command); | ||
| } | ||
| free(dynamicprofiledata); | ||
| dynamicprofiledata = NULL; // Set to NULL to prevent double-free | ||
| } | ||
| } | ||
| else | ||
| { | ||
| strcat(appendcommandstr, dynamicprofiledata->command); | ||
| staticprofiledata->command = appendcommandstr; | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Updated command after append from dynamic and static profile: %s \n", __FUNCTION__, __LINE__, staticprofiledata->command); | ||
| RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Executing Commands in Runtime Service... \n",__FUNCTION__,__LINE__); | ||
| checkIssueNodeInfo(pIssueNode, NULL, rbuf, false, staticprofiledata); | ||
| // NOTE: staticprofiledata is freed by executeCommands() via checkIssueNodeInfo() | ||
| // Do NOT free staticprofiledata here to avoid double-free | ||
| } | ||
| // Free dynamicprofiledata after use | ||
| if (dynamicprofiledata != NULL) | ||
| { | ||
| if (dynamicprofiledata->rfcvalue != NULL) | ||
| { | ||
| free(dynamicprofiledata->rfcvalue); | ||
| } | ||
| if (dynamicprofiledata->command != NULL) | ||
| { | ||
| free(dynamicprofiledata->command); | ||
| } | ||
| free(dynamicprofiledata); | ||
| } | ||
| } | ||
| strcat(appendcommandstr, dynamicprofiledata->command); | ||
| staticprofiledata->command = appendcommandstr; | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "[%s:%d]: Updated command after append from dynamic and static profile: %s \n", __FUNCTION__, __LINE__, staticprofiledata->command); | ||
| RDK_LOG(RDK_LOG_DEBUG,LOG_REMDEBUG,"[%s:%d]: Executing Commands in Runtime Service... \n",__FUNCTION__,__LINE__); | ||
| checkIssueNodeInfo(pIssueNode, NULL, rbuf, false, staticprofiledata); | ||
| } | ||
| } | ||
| } | ||
| else if (rbuf->inDynamic) | ||
| { | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Checking if Issue marked inDynamic... \n", __FUNCTION__, __LINE__); | ||
| processIssueTypeInDynamicProfile(rbuf, pIssueNode); | ||
| } | ||
| else | ||
| { | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Issue not marked as inDynamic... \n", __FUNCTION__, __LINE__); | ||
| RDK_LOG(RDK_LOG_DEBUG, LOG_REMDEBUG, "[%s:%d]: Checking Issue from Static... \n", __FUNCTION__, __LINE__); | ||
| processIssueTypeInStaticProfile(rbuf, pIssueNode); | ||
| } | ||
| //CID-336989: Resource leak | ||
| free(pIssueNode); | ||
| } |
There was a problem hiding this comment.
processIssueType() allocates pIssueNode via malloc() but it is never freed on any path (the previous free(pIssueNode) was removed). Since this runs per event, this introduces an unbounded memory leak in the daemon. Ensure pIssueNode is freed before returning (including error paths), and avoid freeing it inside helpers that don't own it.
| int rrd_upload_cleanup_source_dir(const char *dir_path) { | ||
| if (!dir_path) return -1; | ||
|
|
||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Removing source directory: %s\n", __FUNCTION__, dir_path); | ||
|
|
||
| char cmd[1024]; | ||
| snprintf(cmd, sizeof(cmd), "rm -rf %s", dir_path); | ||
|
|
||
| int ret = system(cmd); | ||
| if (ret == 0) { | ||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Successfully removed source directory: %s\n", | ||
| __FUNCTION__, dir_path); | ||
| return 0; | ||
| } else { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "%s: Failed to remove source directory: %s (ret: %d)\n", | ||
| __FUNCTION__, dir_path, ret); | ||
| return -1; | ||
| } | ||
| } |
There was a problem hiding this comment.
rrd_upload_cleanup_source_dir() builds a shell command and calls system("rm -rf %s"). This is vulnerable to command injection if dir_path contains shell metacharacters, and it also violates the project's stated goal of avoiding system() calls where possible. Replace this with a safe recursive deletion implementation (e.g., nftw()/unlinkat() traversal) and validate that dir_path is within an expected base directory before deleting.
| /* split into prefix and name */ | ||
| size_t prefix_len = name_len - 100 - 1; /* leave room for null */ | ||
| if (prefix_len > sizeof(hdr.prefix)) { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | ||
| __FUNCTION__, name, name_len); | ||
| return -1; | ||
| } | ||
| strncpy(hdr.prefix, name, prefix_len); | ||
| hdr.prefix[prefix_len < sizeof(hdr.prefix) ? prefix_len : sizeof(hdr.prefix) - 1] = '\0'; | ||
| strncpy(hdr.name, name + prefix_len + 1, sizeof(hdr.name) - 1); | ||
| hdr.name[sizeof(hdr.name) - 1] = '\0'; |
There was a problem hiding this comment.
write_tar_header() splits long paths into prefix/name by taking an arbitrary cut (prefix_len = name_len - 101). This doesn't respect tar's requirement that the split occur on a '/' boundary, and can produce archives with invalid/incorrect entry names for paths >100 chars. Prefer splitting at the last '/' that keeps prefix<=155 and name<=100 (or reject paths that can't be represented).
| /* split into prefix and name */ | |
| size_t prefix_len = name_len - 100 - 1; /* leave room for null */ | |
| if (prefix_len > sizeof(hdr.prefix)) { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | |
| __FUNCTION__, name, name_len); | |
| return -1; | |
| } | |
| strncpy(hdr.prefix, name, prefix_len); | |
| hdr.prefix[prefix_len < sizeof(hdr.prefix) ? prefix_len : sizeof(hdr.prefix) - 1] = '\0'; | |
| strncpy(hdr.name, name + prefix_len + 1, sizeof(hdr.name) - 1); | |
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | |
| /* split into prefix and name at a '/' boundary according to POSIX ustar */ | |
| size_t split_index = (size_t)-1; | |
| size_t prefix_len = 0; | |
| size_t name_part_len = 0; | |
| /* search for the rightmost '/' that yields valid prefix/name lengths */ | |
| for (size_t i = name_len; i > 0; --i) { | |
| if (name[i - 1] == '/') { | |
| size_t p_len = i - 1; /* characters before '/' */ | |
| size_t n_len = name_len - i; /* characters after '/' */ | |
| if (p_len > 0 && | |
| p_len <= sizeof(hdr.prefix) - 1 && | |
| n_len > 0 && | |
| n_len <= sizeof(hdr.name) - 1) { | |
| split_index = i - 1; | |
| prefix_len = p_len; | |
| name_part_len = n_len; | |
| break; | |
| } | |
| } | |
| } | |
| if (split_index == (size_t)-1) { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | |
| __FUNCTION__, name, name_len); | |
| return -1; | |
| } | |
| /* copy prefix and name parts, ensuring null termination */ | |
| strncpy(hdr.prefix, name, prefix_len); | |
| hdr.prefix[prefix_len] = '\0'; | |
| strncpy(hdr.name, name + split_index + 1, name_part_len); | |
| hdr.name[name_part_len] = '\0'; |
| mkdir -p /media/apps/RDK-RRD-Test/etc/rrd | ||
|
|
||
| touch /media/apps/RDK-RRD-Test/etc/rrd/remote_debugger.json | ||
| echo "AA:BB:CC:DD:EE:FF" >> /tmp/.estb_mac |
There was a problem hiding this comment.
This appends the mock MAC to /tmp/.estb_mac on every run, which will accumulate multiple lines and can break any code that expects a single MAC value. Use overwrite (>) or truncate the file before writing the mock MAC.
| echo "AA:BB:CC:DD:EE:FF" >> /tmp/.estb_mac | |
| echo "AA:BB:CC:DD:EE:FF" > /tmp/.estb_mac |
| And the issue data node and sub-node should be found in the JSON file | ||
| And the directory should be created to store the executed output | ||
| And Sanity check to validate the commands should be executed | ||
| And Command output shopuld be added to the output file |
There was a problem hiding this comment.
Typo in step text: "shopuld" should be "should".
| THERMAL_TEMPERATURE_CRITICAL = 4 /* Critial Thermal Temperature */ | ||
| } PowerController_ThermalTemperature_t; |
There was a problem hiding this comment.
Typo in enum comment: "Critial" should be "Critical".
| And the issue data node and sub-node should be found in the JSON file | ||
| And the directory should be created to store the executed output | ||
| And Sanity check to validate the commands should be executed | ||
| And Command output shopuld be added to the output file |
There was a problem hiding this comment.
Typo in step text: "shopuld" should be "should".
| // Check BUILD_TYPE for prod override logic (matching shell script lines 81-83) | ||
| bool is_prod_with_override = (strcmp(config->build_type, "prod") != 0 && file_exists("/opt/dcm.properties")); | ||
| if (is_prod_with_override) { | ||
| RDK_LOG(RDK_LOG_WARN, LOG_REMDEBUG, | ||
| "%s: Configurable service end-points will not be used for %s Builds due to overriden /opt/dcm.properties!!!\n", | ||
| __FUNCTION__, config->build_type); | ||
| } else { |
There was a problem hiding this comment.
The boolean name is_prod_with_override doesn't match its condition (BUILD_TYPE != prod && /opt/dcm.properties exists). This makes the override logic hard to reason about and easy to misread. Rename it to reflect the actual condition (e.g., non_prod_with_opt_dcm_override) or adjust the condition to match the name.
* RDKEMW-16897: Add Agentic Support for the RRD * Updated the instructions --------- Co-authored-by: Hanasi <nhanas001c@cable.comcast.com>
…ile Data (#183) * Update rrdInterface.h Update rrdInterface.h Update rrdInterface.c Update rrdInterface.h Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Add helper functions for profile data processing Added helper functions for profile data processing. Update rrdInterface.c Update rrdInterface.h Update Client_Mock.h Add mock implementations for RBusApiWrapper methods Remove mock profile handler functions for GTEST Removed mock implementations for profile handler functions when GTEST_ENABLE is defined. Update Client_Mock.cpp Update Client_Mock.h Update rrdInterface.h Update Makefile.am Update src/rrdInterface.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Create profileTestValid.json Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Update rrdUnitTestRunner.cpp Create profileTestInvalid.json Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Update rrdInterface.c Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdInterface.c Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> fix: add NULL guard to has_direct_commands to prevent crash on NULL input Agent-Logs-Url: https://github.com/rdkcentral/remote_debugger/sessions/c84bc9e8-e1d2-4412-81d4-54eb9c67be5f Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Create test.py Convert run_l2.sh to Python with RDK tests Refactor run_l2.sh to Python and implement RDK Remote Debugger tests. L2 Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdInterface.c fix: correct set_rbus_response to use real rbus API signatures rbusValue_Init() returns rbusValue_t (not rbusError_t) and rbusValue_SetString() returns void in the real rbus library, so capturing their return values as rbusError_t caused a build error. - Remove incorrect return-value capture from rbusValue_Init and rbusValue_SetString; check rbusValue != NULL after init instead - Add NULL guard for prop parameter - Update RRDProfileHandlerTest SetUp() mock so rbusValue_Init actually sets *value to a non-null pointer, keeping SetRbusResponse_ValidInput test passing Agent-Logs-Url: https://github.com/rdkcentral/remote_debugger/sessions/e887c84a-2e12-4903-9d59-2bd6f90e2527 Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Update rrdInterface.c Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> fix: resolve Coverity dead code and add NULL guard to get_all_categories_json - read_profile_json_file: split combined NULL check into two separate checks (file_size first, then filename) so *file_size is safely zeroed before the filename check; eliminates the ternary 'filename ? filename : "(null)"' and the Coverity dead-code report - get_all_categories_json: add early NULL guard for json parameter that returns an empty JSON object string to prevent crash when callers (including unit tests) pass NULL Agent-Logs-Url: https://github.com/rdkcentral/remote_debugger/sessions/c686520e-0adf-4e7e-9915-9b9e4e8a74fd Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdUnitTestRunner.cpp Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdInterface.c Update rrdInterface.c Update rrdUnitTestRunner.cpp Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdUnitTestRunner.cpp Update src/rrdInterface.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdInterface.c Clean up comments in save_profile_category function Removed comments explaining file opening flags. RDKEMW-16897: Add Agentic Support for the RRD (#182) * RDKEMW-16897: Add Agentic Support for the RRD * Updated the instructions --------- Co-authored-by: Hanasi <nhanas001c@cable.comcast.com> Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Rename test.py to test_rrd_profile_data.py rrd Update src/rrdInterface.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update src/rrdInterface.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Update rrdUnitTestRunner.cpp * Update rrdInterface.c * Update rrdUnitTestRunner.cpp
| pid2 = run_shell_command(command_to_get_pid).strip().split() | ||
|
|
||
| # Assert only one PID exists (no second instance) | ||
| assert len(pid2) == 1, f"A second instance of remotedebugger was started: {pid2}" | ||
| # ensure it's the same PID as before | ||
| assert pid1[0] == pid2[0], f"PID changed unexpectedly: before={pid1}, after={pid2}" |
There was a problem hiding this comment.
pid1 can be an empty list if remotedebugger fails to start (or pidof returns nothing). The later pid1[0] indexing will raise IndexError and hide the real failure. Add an explicit assertion that pid1 is non-empty after the start attempt (and possibly assert pid2 is non-empty too) before comparing PIDs.
| AC_ARG_ENABLE([L2support], | ||
| AS_HELP_STRING([--enable-L2support],[enable L2support (default is no)]), | ||
| [ | ||
| case "${enableval}" in | ||
| yes) L2_SUPPORT_ENABLE=true | ||
| L2_SUPPORT_FLAG="-DUSE_L2_SUPPORT" | ||
| m4_if(m4_sysval,[0],[SUBDIRS_L2_SUPPORT="src"]) ;; | ||
| no) L2_SUPPORT_ENABLE=false AC_MSG_ERROR([L2_SUPPORT is disabled]) ;; | ||
| *) AC_MSG_ERROR([bad value ${enableval} for --enable-L2support]) ;; | ||
| esac | ||
| ], | ||
| [echo "L2support is disabled"]) |
There was a problem hiding this comment.
The --enable-L2support option currently sets L2_SUPPORT_FLAG/SUBDIRS_L2_SUPPORT but neither is substituted nor used by any Makefile, so enabling it has no effect. Also, passing --enable-L2support=no hard-errors even though the help says the default is no. Consider (1) AC_SUBST'ing L2_SUPPORT_FLAG and wiring it into AM_CFLAGS/CPPFLAGS, or (2) removing the option if it's not needed, and avoid AC_MSG_ERROR for the 'no' case.
| SCRIPT_SUCCESS = "Debug Information Report upload Failed" | ||
| SCRIPT_FAILURE = "Debug Information Report upload Success" | ||
| if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS): | ||
| print("Script execution success") | ||
| elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE): | ||
| print("Script execution failed") | ||
| else: |
There was a problem hiding this comment.
SCRIPT_SUCCESS/SCRIPT_FAILURE variables are reversed: SCRIPT_SUCCESS is set to the 'upload Failed' log line and SCRIPT_FAILURE to the 'upload Success' line, which makes the printed status misleading. Swap the constants (or rename them) so the variable name matches the log meaning.
| And Command output shopuld be added to the output file | ||
| And the issuetype systemd service should start successfully |
There was a problem hiding this comment.
Typo in step text: "shopuld" → "should".
| And Command output shopuld be added to the output file | ||
| And the issuetype systemd service should start successfully |
There was a problem hiding this comment.
Typo in step text: "shopuld" → "should".
| int rrd_upload_cleanup_source_dir(const char *dir_path) { | ||
| if (!dir_path) return -1; | ||
|
|
||
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Removing source directory: %s\n", __FUNCTION__, dir_path); | ||
|
|
||
| char cmd[1024]; | ||
| snprintf(cmd, sizeof(cmd), "rm -rf %s", dir_path); | ||
|
|
||
| int ret = system(cmd); | ||
| if (ret == 0) { |
There was a problem hiding this comment.
rrd_upload_cleanup_source_dir builds a shell command with an unquoted dir_path and passes it to system("rm -rf %s"). If dir_path is ever influenced by external input, this becomes a command-injection risk and can delete unintended paths (spaces/globs). Prefer a non-shell recursive delete (nftw/unlinkat) and/or strictly validate/escape the directory path before deletion.
| /* Get the device MAC address. | ||
| * @param mac_addr Buffer to store MAC address (min 18 bytes) | ||
| * @param size Size of buffer | ||
| * @return 0 on success, -1 on error | ||
| */ | ||
| int rrd_sysinfo_get_mac_address(char *mac_addr, size_t size); |
There was a problem hiding this comment.
The header comment says the MAC buffer must be at least 18 bytes, but the implementation strips colons and only needs 13 bytes (12 hex chars + NUL). Update the comment to match the actual required size (or change the implementation to return the colon-separated form).
| echo "AA:BB:CC:DD:EE:FF" >> /tmp/.estb_mac | ||
|
|
There was a problem hiding this comment.
This appends to /tmp/.estb_mac on every run, which can create a multi-line MAC file and break consumers expecting a single MAC value. Use overwrite (>) or ensure the file is truncated before writing.
RRD release for static profile DML
No description provided.